import request from '@/config/axios'

// 评测任务 VO
export interface EvaluationTaskVO {
  id: number // ID
  name: string // 任务名称
  type: number // 评测类型 0 单个评测，1 对比评测
  datasetTypeIds: string // 数据集集合，逗号隔开
  largeModelIds: string // 模型集合，逗号隔开
  status: number // 推理状态（0 待推理，1 推理中， 2 推理完成）
  indicator1Weight: number
  indicator2Weight : number
  indicator3Weight : number
  indicator4Weight : number
  indicator5Weight : number
  indicator6Weight : number
  indicator7Weight : number
  indicator8Weight : number
  indicator9Weight : number
  singleModelName?: string
  finishNum?: number
  totalNum?: number
  hasChildren?: boolean
  children?: TaskChildrenVO[]
}

export interface TaskChildrenVO {
  id: number // ID
  name: string // 任务名称
  type: number | null // 评测类型 0 单个评测，1 对比评测
  createTime: string
  finishNum?: number
  singleModelName?: string
  totalNum?: number
  status: number
}

export interface EvaluationWeightVO {
  id: number // ID
  indicator1Weight: number
  indicator2Weight : number
  indicator3Weight : number
  indicator4Weight : number
  indicator5Weight : number
  indicator6Weight : number
  indicator7Weight : number
  indicator8Weight : number
  indicator9Weight : number
}

// 评测任务 API
export const EvaluationTaskApi = {
  // 查询评测任务分页
  getEvaluationTaskPage: async (params: any) => {
    return await request.get({ url: `/multiModel/evaluation-task/page`, params })
  },

  // 评测任务分页列表模型明细
  getEvaluationTaskModelStat: async (params: any) => {
    return await request.get({ url: `/multiModel/evaluation-task/model-stat`, params })
  },

  // 查询评测任务详情
  getEvaluationTask: async (id: number) => {
    return await request.get({ url: `/multiModel/evaluation-task/get?id=` + id })
  },

  // 新增评测任务
  createEvaluationTask: async (data: EvaluationTaskVO) => {
    return await request.post({ url: `/multiModel/evaluation-task/create`, data })
  },

  // 修改评测任务
  updateEvaluationTask: async (data: EvaluationTaskVO) => {
    return await request.put({ url: `/multiModel/evaluation-task/update`, data })
  },

  // 删除评测任务
  deleteEvaluationTask: async (id: number) => {
    return await request.delete({ url: `/multiModel/evaluation-task/delete?id=` + id })
  },

  // 导出评测任务 Excel
  exportEvaluationTask: async (params) => {
    return await request.download({ url: `/multiModel/evaluation-task/export-excel`, params })
  },

  // 模型推理
  getModelInference: async (id: number) => {
    return await request.get({ url: `/multiModel/evaluation-task/model-inference?id=` + id })
  },  

  // 查询评测任务
  getEvaluationTaskInfo: async (id: number) => {
    return await request.get({ url: `/multiModel/evaluation-task/get?id=` + id })
  },

  // 更新评测任务指标权重
  updateEvaluationWeight: async (data: EvaluationWeightVO) => {
    return await request.put({ url: `/multiModel/evaluation-task/update-weight`, data })
  }, 

  // 模型评分
  getModelEvaluation: async (params: any) => {
    return await request.get({ url: `/multiModel/evaluation-task/model-evaluation`, params })
  },

  // 评测统计
  getEvaluateStat: async (params?: any) => {
    return await request.get({ url: `multiModel/evaluation-task-item/evaluate-stat`, params })
  },

  // 终止评测任务
  shutdownTask: async (data: EvaluationTaskVO) => {
    return await request.post({ url: `/multiModel/evaluation-task/shutdown-task`, data })
  }
}
